import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/Home.vue';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Home',
    meta: {
      title: '我的信用卡',
    },
    component: Home,
  },
  {
    path: '/footprint',
    name: '/footprint',
    meta: {
      title: '全球足迹',
    },
    component: () => import('../views/footprint.vue'),
  },
  {
    path: '/happenBill',
    name: 'happenBill',
    meta: {
      title: '账单明细',
    },
    component: () => import('../views/happenBill.vue'),
  },
  {
    path: '/billCycle',
    name: 'billCycle',
    meta: {
      title: '补打账单',
    },
    component: () => import('../views/billCycle.vue'),
  },
  {
    path: '/billDetail',
    name: 'billDetail',
    meta: {
      title: '账单详情',
    },
    component: () => import('../views/billDetail.vue'),
  },
  {
    path: '/installment',
    name: 'installment',
    meta: {
      title: '账单分期',
    },
    component: () => import('../views/installment.vue'),
  },
  {
    path: '/annualFee',
    name: 'annualFee',
    meta: {
      title: '我的年费',
    },
    component: () => import('../views/annualFee.vue'),
  },
  {
    path: '/billRepayment',
    name: 'billRepayment',
    meta: {
      title: '账单还款',
    },
    component: () => import('../views/billRepayment.vue'),
  },
  {
    path: '/paymentSuccess',
    name: 'paymentSuccess',
    meta: {
      title: '还款成功',
    },
    component: () => import('../views/paymentSuccess.vue'),
  },
  {
    path: '/deleteSuccess',
    name: 'deleteSuccess',
    meta: {
      title: '删除成功',
    },
    component: () => import('../views/deleteSuccess.vue'),
  },
  {
    path: '/addCard',
    name: 'addCard',
    meta: {
      title: '新增账户',
    },
    component: () => import('../views/addCard.vue'),
  },
  {
    path: '/otherPayment',
    name: 'otherPayment',
    meta: {
      title: '还款账户',
    },
    component: () => import('../views/otherPayment.vue'),
  },
  {
    path: '/manageOtherCard',
    name: 'manageOtherCard',
    meta: {
      title: '还款账户',
    },
    component: () => import('../views/manageOtherCard.vue'),
  },
  {
    path: '/addOtherCard',
    name: 'addOtherCard',
    meta: {
      title: '新增账户',
    },
    component: () => import('../views/addOtherCard.vue'),
  },
  {
    path: '/agreedRepayment',
    name: 'agreedRepayment',
    meta: {
      title: '约定还款',
    },
    component: () => import('../views/agreedRepayment.vue'),
  },
  {
    path: '/activity',
    name: 'activity',
    meta: {
      title: '活动专区',
    },
    component: () => import('../views/activity.vue'),
  },
  {
    path: '/historyDetail',
    name: 'historyDetail',
    meta: {
      title: '历史明细',
    },
    component: () => import('../views/historyDetail.vue'),
  },
  {
    path: '/historyDetailItem',
    name: 'historyDetailItem',
    meta: {
      title: '详细信息',
    },
    component: () => import('../views/historyDetailItem.vue'),
  },
  {
    path: '/historyTimePick',
    name: 'historyTimePick',
    meta: {
      title: '筛选',
    },
    component: () => import('../views/historyTimePick.vue'),
  },
  {
    path: '/analysis',
    name: 'analysis',
    meta: {
      title: '消费分析',
    },
    component: () => import('../views/analysis.vue'),
  },
];

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes,
});

router.afterEach((to) => {
  document.title = to.meta.title || `农行商户账单`;
});

export default router;
